#include <bits/stdc++.h>
using namespace std;
int n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin >> n >> l >> r;
	if(r-l>=n){
		n--;
		cout << n;
	}
	else if(l-r==0){
		cout << n%l;
	}
	else{
		int lz=0;
		for (int i=l;i<=r;i++){
			lz=max(lz,i%n);
			if(lz==n-1){
				break;
			}
		}
		cout << lz;
	}
	return 0;
}
